﻿//mui初始化
mui.init();
mui.plusReady(initSomething);
//基础样式
var subpage_style = {
	top: '0px',
	bottom: '51px',
	scrollIndicator: 'none'
};
function initSomething() {
	//仅支持竖屏显示
	plus.screen.lockOrientation("portrait-primary");
	// 设置系统状态栏背景色
	plus.navigator.setStatusBarBackground("#ff0000");
	plus.navigator.setFullscreen(false);
	plus.navigator.setStatusBarStyle("UIStatusBarStyleBlackTranslucent");
	var self = plus.webview.currentWebview();
	var sub = plus.webview.create('app/home/app.html', 'app/home/app.html',subpage_style);
	self.append(sub);
}

var activeTab = 'app/home/app.html';
var title = $("#title");
var subpages = ['app/home/app.html', 'app/contact/contact.html','app/notice/notice.html', 'app/me/me.html'];
//添加底部监听
mui('.mui-bar-tab').on('tap', 'a', function(e) {
	var targetTab = this.getAttribute('href');
	if (targetTab == activeTab) {
		return;
	}
	//更换样式
	$(this).find(".mui-icon").addClass("active");
	$(this).siblings().find(".mui-icon").removeClass("active");
	//打开当前webview，关闭其他webview
	for (var i = 0; i < 5; i++) {
		if (targetTab == subpages[i]) {
			var newWebview = plus.webview.create(targetTab, targetTab, subpage_style);
			plus.webview.show(newWebview);
			activeTab = targetTab;
		} else {
			plus.webview.close(subpages[i]);
		}
	}
})

